{if $formule->status=='0'} {assign $non = "CHECKED"}{else}{assign $non = ""}{/if}
{if $formule->status=='1'} {assign $oui = "CHECKED"}{else}{assign $oui = ""}{/if}
 
<div id="main_container">

    {$oZoneHeader}
    {literal} 
          <script type="text/javascript">
                $(function(){
                    $( "#datepicker" ).datepicker({dateFormat: 'dd/mm/yy'});
                    $( "#datepicker2" ).datepicker({dateFormat: 'dd/mm/yy'});
                });
            </script> 
     {/literal}
     
    <div class="main_content">
        {$oZoneTopMenu}
        <div class="center_content">  
            <div class="left_content">
                {$oZoneLeftMenu}
            </div>
        
       
            <div id="lformulaires" class="right_content">
        
                {if $id}
                    <h2>Editer une formule</h2> 
                    {assign $disabled = "DISABLED"}
                {else}
                    <h2>Ajouter une formule</h2> 
                    {assign $disabled = ""}

                {/if} 
               <form id="createForm" action="{jurl 'formule~BoFormule:sauvegarder'}" method="POST">
                  <input type="hidden" name="id" value="{$formule->id}" />
                  <dl>
                    <dt><label>Titre : </label></dt>
                    <dd><input type="text"  value="{$formule->titre}" name="titre" /></dd>
                  </dl>
                  <dl>
                    <dt><label>Prix : </label></dt>
                    <dd><input type="text" value="{$formule->prix}"  name="prix"/></dd>
                  </dl>
                  {foreach $toOptions as $iKeyOption => $oOption}
                  <dl>
                    <dt><label>{$oOption->lib_option_formule|escxml} : </label></dt>
                    <dd>
                        <select id="parution_{$iKeyOption}" name="parution[]" class="list-opt" opt="{$oOption->id_option_formule}">
                            <option value="">Selectionner</option>
                            {foreach $oOption->toChoises as $iKey => $oChoise}

                            <option value="{$iKey}" opt="{$oChoise->formch_id}" {if in_array($oChoise->formch_id, $tabOpt)}selected="selected"{/if}>{$oChoise->formch_libelle|escxml}</option>
                            {/foreach}
                        </select>
                    </dd>
                  </dl>
                  {/foreach}
                  <input type="hidden" value="" id="choix-associated" name="choix-associated" />
                  {literal}
                    <script type="text/javascript">
                    $(function () {
                    $('#valid-form').click(function () {
                        _collector = "";
                        k = 0;
                        $('.list-opt').each(function () {
                            _currentVal = $(this).val();
                            
                            if (_currentVal != "")
                            {
                                sep = (k>0)? ',' : '';
                                _collector += sep + $(this).children('option:selected').attr('opt');
                                k++;
                            }
                        });
                        $('#choix-associated').val(_collector);
                        document.forms['createForm'].submit();
                      
                    });
                    });
                    </script>
                  {/literal}
                  <dl style="height:auto">
                    <dt><label>Descriptif : </label></dt>
                    <dd style="width:620px;">
                        <textarea class="ckeditor" cols="80" id="editor1" name="content" rows="10">{$formule->content}</textarea>
                    </dd>
                  </dl>
                  <dl style="height:auto">
                    <div class="dt1">
                      <label class="no-marge">Date de debut : </label>
                      <input type="text" id="datepicker" name="debut"  value="{$formule->date_debut|jdatetime:'db_date':'lang_date'}" />
                    </div>
                    <div class="dt2">
                      <label class="no-marge">Date de fin : </label>
                      <input type="text" id="datepicker2" name="fin" value="{$formule->date_fin|jdatetime:'db_date':'lang_date'}" />
                    </div>
                  </dl>


                 <dl>
                    <dt><label class="nPadd">Statut : </label></dt>
                    <dd><input type="radio" name="status"  value="1" {$oui}/><span>activer</span><input type="radio" name="status" value="0" {$non}/><span>désactiver</span></dd>
                 </dl>

                 <dl class="submit">
                            <a title="Valider" href="#" class="bt_blue" id="valid-form"><span class="bt_blue_lft"></span><strong>Valider</strong><span class="bt_blue_r"></span></a>
                            <a title="Annuler" href="{jurl 'formule~BoFormule:index'}" class="bt_green"><span class="bt_green_lft"></span><strong>Annuler</strong><span class="bt_green_r"></span></a>
                 </dl>  

               </form>
            </div><!-- end of right content-->
       
        </div>   <!--end of center content -->               

        <div class="clear"></div>
    </div> <!--end of main content-->
    
    
    <div class="footer">
    </div>

</div>      
